<?php
/**
 *
 * PHP versions 5
 *
 * Copyright (C)
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of ERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software
 * Fundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 *
 * @author Bastian Schröder <bs@chemanet.de>
 * @version 2007-07-27
 * @package rail
 */

require_once( 'railadmin.conf.php' );
require_once( "$cfg_pahToPHPrail/rail_connector.class.php" );


define( 'RAILADMIN_TEMPLATE', isset($_GET['tpl']) ? $_GET['tpl'] . '.tpl' : 'login.tpl' );

exec('/usr/local/bin/svn info ./', $svn_info);
define('RAILADMIN_REVISION', substr($svn_info[2], strpos($svn_info[2], ': ') + 2 ) );
define('RAILADMIN_VERSION', '2.0');

session_start();

/* ---------------------------------- Parse template ---------------------------------- */
$template = new rail_smarty();
$template->caching = false;
if( is_file( substr( RAILADMIN_TEMPLATE, 0, strpos( RAILADMIN_TEMPLATE, '.' ) ) . '.php' ) )
	include_once( substr( RAILADMIN_TEMPLATE, 0, strpos( RAILADMIN_TEMPLATE, '.' ) ) . '.php' );


/* -------------------------------------- Display ------------------------------------- */
$frame = new rail_smarty();
$frame->caching = false;
$frame->assign( array(
	'railversion_info' => PHPrail_VERSION . '-' . PHPrail_REVISION,
	'railadminversion_info' => RAILADMIN_VERSION . '-' . RAILADMIN_REVISION,
	'connect_info' => (isset($_SESSION['mysql_host']) ? $_SESSION['mysql_user'] . '@' . $_SESSION['mysql_host'] . ( isset($_SESSION['mysql_db']) ? ':' . ( isset($rail) ? $rail->get_user()->get_name() . ':' : '' ) . $_SESSION['mysql_db'] : '') : 'nicht verbunden'),
	'tpl' => substr( RAILADMIN_TEMPLATE, 0, strpos( RAILADMIN_TEMPLATE, '.' ) ),
	'template' => $template->fetch( RAILADMIN_TEMPLATE )
));
$frame->display( 'frame.tpl' );

?>